<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>

<html>
	<head>
		<title>IdeaPad - Idea: <bean:write name="showIdeaForm" property="name" /></title>
		<link rel="stylesheet" type="text/css" href="styles/main.css">
		<link rel="stylesheet" type="text/css" href="styles/buttons.css">
	</head>
	<body>
		<div class="header">
			<html:link action="/default"><img src="/IdeaPad/images/ideapad_logo.png" alt="logo" border="0"/></html:link>
			<%
		if(session.getAttribute("username") == null || session.getAttribute("username") == ""){
			%>
			<html:link page="/form/login.jsp" styleClass="menubuttons">Login</html:link>
			<html:link page="/form/registerUser.jsp" styleClass="menubuttons">Register</html:link>
			<%
		}
		else{
			%>
			Hello 
			<%=
			session.getAttribute("username").toString() %>
			<html:link action="viewGroups" styleClass="menubuttons">Groups</html:link>
			<html:link action="manageGroups" styleClass="menubuttons">Manage Groups</html:link>
			<html:link page="/form/editUserSettings.jsp" styleClass="menubuttons">Settings</html:link>
			<html:link action="logout" styleClass="menubuttons">Logout</html:link>
			<%
		}
		 %>
		</div>
		<h1>Idea Name: <bean:write name="showIdeaForm" property="name" /></h1>
		<table border="1">
		<tbody>
			<tr>
				<td>
					Vote Count:
				</td>
				<td>
					<bean:write name="showIdeaForm" property="voteCount" />
				</td>
			</tr>
			<tr>
				<td>
					Last edited: 
				</td>
				<td>
					<bean:write name="showIdeaForm" property="lastEdit" />
				</td>
			</tr>
			<tr>
				<td>
					Abstract:
				</td>
				<td>
					<bean:write name="showIdeaForm" property="abstractText" />
				</td>
			</tr>
			<tr>
				<td>
					Body:
				</td>
				<td>
					<bean:write name="showIdeaForm" property="bodyText" />
				</td>
			</tr>
			<tr>
				<td><strong>Vote:</strong></td>
				<td>
				<logic:empty name="showIdeaForm" property="votedValue">
					<html:link action="/showIdea">
						UP
						<html:param name="ideaId"><bean:write name="showIdeaForm" property="ideaId"/></html:param>
						<html:param name="vote" value="1" />
					</html:link>
					<br />
					<br />
					<html:link action="/showIdea">
						DOWN
						<html:param name="ideaId"><bean:write name="showIdeaForm" property="ideaId"/></html:param>
						<html:param name="vote" value="-1" />
					</html:link>
				</logic:empty >
				<logic:notEmpty name="showIdeaForm" property="votedValue">You have voted "<bean:write name="showIdeaForm" property="votedValue"/>" for this idea</logic:notEmpty>
				</td>
			</tr>
			</tbody>
		</table>
		<br />
		<h2>Comments</h2><table border="1">
		<tbody>
		<tr>
		<td>User</td><td>Comment</td><td>Date</td>
		</tr>
		<logic:empty name="showIdeaForm" property="comments">
		<tr>
			<td colspan="3">No Comments</td>
		</tr>
		</logic:empty>
		<logic:notEmpty name="showIdeaForm" property="comments">
		<logic:iterate name="showIdeaForm" property="comments" id="comment">
		<tr>
			<td><bean:write name="comment" property="userName" /></td>
			<td><bean:write name="comment" property="commentText" /></td>
			<td><bean:write name="comment" property="lastEdit" /></td>
		</tr>
		</logic:iterate>
		</logic:notEmpty>
		</tbody>
		</table>
		<h3>Write a Comment:</h3>
		<html:form action="/postComment">
			<html:textarea name="showIdeaForm" property="comment" ></html:textarea>
			<html:submit value="Submit Comment"></html:submit>
		</html:form>
	</body>
</html>

